- reward = f.object

.nested-fields
  .reward-card
    - if reward.persisted?
      .w-row.card-persisted.card.card-terciary.u-marginbottom-20.medium[id="reward_#{reward.id}" data-update_url=sort_project_reward_path(@project, reward) class="sortable"]
        .w-col.w-col-5.w-sub-col
          .fontweight-semibold.fontsize-smallest.u-marginbottom-10
            = t('projects.dashboard_reward.reward')
        .w-col.w-col-7
          .card
            .w-row
              .w-col.w-col-11.w-col-small-11.w-col-tiny-11
                .fontsize-base.fontweight-semibold= t('rewards.index.reward_title', minimum: reward.display_minimum).html_safe
              .w-col.w-col-1.w-col-small-1.w-col-tiny-1
                = link_to "javascript:void(0);", data: {target: ".edit_reward_content_#{reward.id}", parent: "#reward_#{reward.id}"}, class: 'show_reward_form' do
                  .btn.btn-small.btn-terciary.fa.fa-lg.fa-edit.btn-no-border
            .fontsize-smaller.u-marginbottom-20.fontweight-semibold= pluralize(reward.payments.with_state('paid').count(:all), t('contribution_singular'), t('contribution_plural'))
            p.fontsize-small
              br= reward.display_description
            - if reward.maximum_contributions
              - in_time_to_confirm = reward.in_time_to_confirm
              - if in_time_to_confirm > 0
                .maximum_contributions.in_time_to_confirm.clearfix
                  .pending.fontsize-smallest.fontcolor-secondary= t('rewards.index.contributions_to_confirm', count: in_time_to_confirm)
              - if reward.sold_out?
                .u-margintop-10
                  span.badge.badge-gone.fontsize-smaller
                    = t('rewards.index.sold_out')
              - else
                .u-margintop-10
                  span.badge.badge-attention.fontsize-smaller
                    span.fontweight-bold
                      => t('rewards.index.limited')
                    = " (" + reward.display_remaining + ")"
            .fontsize-smallest
              =t('rewards.index.reward_deliver_time', estimate: reward.display_deliver_estimate).html_safe
  
    .w-row.card.card-terciary.u-marginbottom-20.card-edition.medium class=(reward.new_record? ? '' : "w-hidden edit_reward_content_#{reward.id}")
      .w-col.w-col-5.w-sub-col
        .fontweight-semibold.fontsize-smallest.u-marginbottom-10
          - if reward.new_record?
            | #{t('.reward')} #
          - else
            = t('.edit')
          |&nbsp;
          a.link-edit.fa.fa-question-circle href="javascript:void(0);"
        .fontsize-smallest.fontcolor-secondary.reward-explanation.w-hidden.u-marginbottom-20= t('.info_box')
      .w-col.w-col-7
        .card
          .w-form
            .w-row.u-marginbottom-20
              .w-col.w-col-5
                label.fontsize-smaller= t('.minimum_value') 
              .w-col.w-col-7
                .w-row
                  .w-col.w-col-3.w-col-small-3.w-col-tiny-3.text-field.positive.prefix.no-hover
                    .fontsize-smallest.fontcolor-secondary.u-text-center R$
                  .w-col.w-col-9.w-col-small-9.w-col-tiny-9
                    = f.input_field :minimum_value, as: :tel, class: 'postfix positive', required: true
                .fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="reward_minimum_value"] = t('simple_form.validation_texts.reward.minimum_value')
            .w-row
              .w-col.w-col-5
                label.fontsize-smaller= t('.deliver_at') 
              .w-col.w-col-7
                .w-row
                  .w-col.w-col-12
                    .w-row
                      = f.input_field :deliver_at, required: true, as: :date, discard_day: true, start_year: Time.current.year, use_short_month: true, discard_day: true, required: true, class: 'w-col-6 positive'
            .w-row
              .w-col.w-col-5
                label.fontsize-smaller= t('.description') 
              .w-col.w-col-7
                = f.input_field :description, as: :text,  class: 'positive', placeholder: "Descreva sua recompensa", required: true
                .fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="reward_description"] = t('simple_form.validation_texts.reward.description')
            .w-row
              .w-col.w-col-5
                .w-checkbox
                  .w-checkbox-input= check_box_tag  "limit_reward", '', (reward.maximum_contributions.present?), id: 'limit_reward' 
                  label.w-form-label for="limit_reward"= t('.limit_reward') 
              .w-col.w-col-7 class="reward_maximum_contributions #{reward.maximum_contributions.present? ?  '' : 'w-hidden'}"
                = f.input_field :maximum_contributions, as: :tel, class: 'u-marginbottom-30 positive', placeholder: t('.available')
            .w-row.u-margintop-30
              /.w-col.w-col-6.w-col-small-6.w-col-tiny-6.w-sub-col-middle
                = f.button :submit, t('.submit'),  class:'btn btn-small'
              - if reward.persisted?
                .w-col.w-col-5.w-col-small-5.w-col-tiny-5.w-sub-col-middle
                  input.w-button.btn-terciary.btn.btn-small.reward-close-button type="submit" value="Fechar" 
              - if reward.new_record? || (reward.persisted? && policy(reward).destroy?)
                .w-col.w-col-1.w-col-small-1.w-col-tiny-1
                  = link_to_remove_association f, data: { confirm: 'Tem certeza?' } do
                    .btn.btn-small.btn-terciary.fa.fa-lg.fa-trash.btn-no-border
